import pygame
from pygame.locals import *


def draw_sprite(screen, sprite):
	pass

def draw_ball(screen):
	screen.blit(images['ball'], (	field.ball.loc[0]*16+field.map_rect.x, 
									field.ball.loc[1]*16+field.map_rect.y, 16,16))

def draw_menu(screen, images, mode, rect, p):
	if p:
		if p.has_moves():
			screen.blit(images['move_icon'], (rect.x,rect.y,50,32))
		else:
			screen.blit(images['move_off'], (rect.x,rect.y,50,32))
	else:
		screen.blit(images['move_off'], (rect.x,rect.y,50,32))
	
	screen.blit(images['hit_icon'], (rect.x+50,rect.y,50,32))
	screen.blit(images['pickup_icon'], (rect.x+100,rect.y,50,32))
	if mode == 'move':
		if p:
			if p.has_moves():
				screen.blit(images['selected_icon'], (rect.x,rect.y,32,32))
	elif mode == 'hit':
		screen.blit(images['selected_icon'], (rect.x+32,rect.y,32,32))

def draw_dice(screen, images, rect):
	screen.blit(images['push'], (rect.x, rect.y, 25, 25))
	screen.blit(images['pow'], (rect.x+25, rect.y, 25, 25))
	screen.blit(images['kapow'], (rect.x+50, rect.y, 25, 25))

def draw_selected(screen, p, rect):
	tile = pygame.Surface((23,23), flags=SRCALPHA)
	tile.fill((255,255,0))
	tile.set_alpha(90)
	screen.blit(tile,((p.loc[0])*25+rect.x, 
					  (p.loc[1])*25+rect.y, 25,25))
	tile.fill((0,0,255))
	tile.set_alpha(110)
	adj = p.get_adj()
	for a in adj:
		screen.blit(tile,((a[0]*25)+rect.x+1, 
						  (a[1]*25)+rect.y+1, 23,23))
	

def draw_field(screen, rect, image):
	""" Draws the field TODO: This might not be in the right place.
	"""
	screen.blit(image, rect)

def draw_players(screen, teams, rect, image):
	""" Draws the players TODO: This might not be in the right place.
	"""
	for t in teams:
		for p in t.players:
			if p.has_moves():
				image.set_alpha(255)
				screen.blit(image, (	(p.loc[0])*25+rect.x, 
											(p.loc[1])*25+rect.y, 25,25))
			else:
				image.set_alpha(100)
				screen.blit(image, (	(p.loc[0])*25+rect.x, 
											(p.loc[1])*25+rect.y, 25,25))

